home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Exchange
/
CD Exchange - Volume 1.iso
/
education
/
gravity-well
/
gw-include.h
< prev
next >
Wrap
Text File
|
1989-09-24
|
17KB
|
480 lines
/*
GW-Include.h
Shared code include for Gravity-Well
Gary Teachout
Copyright July 1989
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>
#include <graphics/gfxmacros.h>
#include <string.h>
#include <math.h>
#include <float.h>
#define LINEPEN 1 /* pen colors */
#define DOTPEN 3
#define BPEN 2
#define DPEN 0
#define MFPEN 0
#define MBPEN 2
#define NEWCENTER 1 /* awaiting */
#define NEWPOSITION 2
#define NEWVELOCITY 3
#define NEWMASS 4
#define NEWCREATE 5
struct dv /* double 3 - d vector */
{ double x , y , z ; } ;
struct obv /* orthogonal basis vectors */
{ struct dv i , j , k ; } ;
struct object /* data for each body */
{
struct dv position ,
velocity ,
oldpos ,
startpos ,
startvel ;
double mass ,
startmass ,
radius ;
short flags ,
collision ;
char name[ 68 ] ;
} ;
struct filedata /* data for the entire simulation */
{
char tag[ 16 ] ;
struct object objects[ 20 ] ;
struct obv viewbasis ,
unviewbasis ;
struct dv viewoffset ;
double elapsedtime ,
timestep ,
scale ,
magic ;
USHORT stopflag ,
awaiting ,
trailson ,
objectnum ,
follow ;
char filecomment1[ 66 ] ,
filecomment2[ 66 ] ;
} ;
struct menubox /* text menu items */
{
struct MenuItem item ;
struct IntuiText text ;
} ;
/* System prototypes */
char *AllocMem() ;
struct Screen *OpenScreen() ;
struct Window *OpenWindow() ;
struct IntuiMessage *GetMsg() ;
struct FileHandle *Open() ;
struct TextFont *OpenDiskFont() ;
/* GW-Main prototypes */
void main( void ) ;
void takestep( double ) ;
/* GW-Interface prototypes */
void startup( void ) ;
void cleanup( void ) ;
void openmainview( void ) ;
void opentopview( void ) ;
void openrightview( void ) ;
void openviewcontrol( void ) ;
void pixel( struct Window * , double , double ) ;
void blankwindow( struct Window * ) ;
void line( struct Window * , double , double , double , double ) ;
void linelong( struct Window * , long , long , long , long ) ;
void interface( void ) ;
void readmes( void ) ;
void handelmenu( void ) ;
void stoploop( void ) ;
void resetdisplay( void ) ;
void screentitle( long ) ;
void setupdisplay( struct Window * ) ;
void set( void ) ;
void create( void ) ;
void setstrings( void ) ;
void deleteobject( long ) ;
void endtrail( long , long ) ;
void updatedisplay( void ) ;
/* GW-Vectors prototypes */
void rotatedv( struct dv * , struct dv * , double * , double * ) ;
void rotatedvpair10( struct dv * , struct dv * ) ;
void adddv( struct dv * , struct dv * , struct dv * ) ;
void subdv( struct dv * , struct dv * , struct dv * ) ;
void scaledv( struct dv * , double * , struct dv * ) ;
void dotdv( struct dv * , struct dv * , double * ) ;
void crossdv( struct dv * , struct dv * , struct dv * ) ;
void magdv( struct dv * , double * ) ;
void basis( struct dv * , struct obv * , struct dv * ) ;
/* Global Data */
/* all but one file must be compiled with the -x option */
struct IntuitionBase *IntuitionBase ;
struct GfxBase *GfxBase ;
struct Library *DiskfontBase ;
struct IntuiMessage *mes ;
struct Screen *screen ;
struct Window *control , /* renamed the Data window */
*viewcontrol ,
*mainview ,
*topview ,
*rightview ;
struct TextAttr stext = { "topaz.font" , 8 , 0 , 0 } ;
struct TextAttr rtext = { "topaz.font" , 11 , 0 , 0 } ;
struct TextFont *rfont ;
ULONG class ;
USHORT code ;
short mousex ,
mousey ;
struct Gadget *iadd ;
char *titletext[ 6 ] =
{
" Gravity Well" ,
" Gravity Well Awating New Center Point" ,
" Gravity Well Awating New Position" ,
" Gravity Well Awating New Velocity" ,
" Gravity Well Awating New Mass" ,
" Gravity Well Create Mode"
} ;
char ettext[ 33 ] ;
char numbertext[] =
" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 " ;
char *controlgtext[ 11 ] =
{
"Position" , "Velocity" , "Mass " ,
"Delete " , "Zero M " , "Start " ,
" Load " , " Save " , " New " ,
" Create " , " Enter "
} ;
char *conlabel[ 10 ] =
{
"File Name:" ,
"Comment:" ,
"" ,
"Name:" ,
"Time Step:" ,
"Magic:" ,
"Mass:" ,
"Radius:" ,
"Start Position:" ,
"Start Velocity:"
} ;
short conlabellength[ 10 ] =
{ 10 , 8 , 0 , 5 , 10 , 6 , 5 , 7 , 15 , 15 } ;
short clut[ 4 ][ 3 ] = /* screen colors */
{
{ 0 , 0 , 0 } ,
{ 15 , 0 , 0 } ,
{ 10 , 8 , 0 } ,
{ 15 , 15 , 15 }
} ;
struct NewScreen ns =
{
0 , 0 , 640 , 400 , 2 , DPEN , BPEN , HIRES | LACE ,
CUSTOMSCREEN , NULL , " Gravity Well" , NULL , NULL
} ;
struct NewWindow
controlnw = /* the Data window */
{
0 , 12 , 640 , 388 , DPEN , BPEN , MENUPICK | GADGETUP ,
WINDOWDEPTH
| SMART_REFRESH | ACTIVATE ,
NULL , NULL , " Data " ,
NULL , NULL , 0 , 0 , 0 , 0 , CUSTOMSCREEN
} ,
viewcontrolnw =
{
490 , 0 , 100 , 173 , DPEN , BPEN , CLOSEWINDOW | MENUPICK | GADGETUP ,
WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH
| SMART_REFRESH ,
NULL , NULL , "VC " ,
NULL , NULL , 0 , 0 , 0 , 0 , CUSTOMSCREEN
} ,
mainviewnw =
{
80 , 92 , 460 , 308 , DPEN , BPEN ,
CLOSEWINDOW | NEWSIZE | MENUPICK | MOUSEBUTTONS ,
WINDOWCLOSE | WINDOWDRAG | WINDOWSIZING | WINDOWDEPTH
| SMART_REFRESH ,
NULL , NULL , " Main View " ,
NULL , NULL , 100 , 80 , 640 , 400 , CUSTOMSCREEN
} ,
topviewnw =
{
80 , 12 , 460 , 80 , DPEN , BPEN ,
CLOSEWINDOW | NEWSIZE | MENUPICK | MOUSEBUTTONS ,
WINDOWCLOSE | WINDOWDRAG | WINDOWSIZING | WINDOWDEPTH
| SMART_REFRESH ,
NULL , NULL , " Top View " ,
NULL , NULL , 100 , 80 , 640 , 400 , CUSTOMSCREEN
} ,
rightviewnw =
{
540 , 92 , 100 , 308 , DPEN , BPEN ,
CLOSEWINDOW | NEWSIZE | MENUPICK | MOUSEBUTTONS ,
WINDOWCLOSE | WINDOWDRAG | WINDOWSIZING | WINDOWDEPTH
| SMART_REFRESH ,
NULL , NULL , " Right View " ,
NULL , NULL , 100 , 80 , 640 , 400 , CUSTOMSCREEN
} ;
struct Menu menustrip[ 3 ] = /* all windows share this menu strip */
{
{ NULL , 1 , 0 , 120 , 10 , MENUENABLED , " QUIT" , NULL } ,
{ NULL , 121 , 0 , 120 , 10 , MENUENABLED , " Open Window" , NULL } ,
{ NULL , 241 , 0 , 120 , 10 , MENUENABLED , " Control" , NULL }
} ;
struct menubox
menu0[ 1 ] =
{
{
{ NULL , 0 , 0 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "QUIT" , NULL }
}
} ,
menu1[ 5 ] =
{
{
{ NULL , 0 , 0 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "Main View" , NULL }
} ,
{
{ NULL , 0 , 14 , 130 , 14 , ITEMTEXT | ITEMENABLED | HIGHCOMP ,
0 , NULL , NULL , 0 , NULL , 0 } ,
{ MFPEN , MBPEN , JAM1 , 15 , 2 , NULL , "Top View" , NULL }
} ,
{
{ NULL , 0 , 28 , 130 , 14 ,